package org.david.code.service;

import java.io.Serializable;
import java.util.List;
import java.util.Map;

import org.hibernate.criterion.DetachedCriteria;
/**
 * 泛型Service，满足通用的增删改查(CRUD)的操作
 * @author davidxiaozhi 
 * @param <T> a type variable
 */ 
public interface IGenericService<T> {

	/**
	 * 根据id得到一个对象
	 * @param id
	 * @return
	 */
	T get(Serializable id);
	
	/**
	 * 根据查询条件得到一个对象
	 * @param query
	 * @return
	 */
	T getUniqueResult(final DetachedCriteria query);
	
	/**
	 * 根据查询条件得到对象的数量
	 * @param query
	 * @return
	 */
	int getCount(DetachedCriteria query);
	
	/**
	 * 根据查询条件得到对象列表
	 * @param query
	 * @return
	 */
	List<T> getList(DetachedCriteria query);
	
	/**
	 * 根据查询条件得到分页对象列表
	 * @param query
	 * @param firstResult
	 * @param maxResults
	 * @return
	 */
	List<T> getList(DetachedCriteria query, int firstResult, int maxResults);
	
	/**
	 * 删除一个对象
	 * @param object
	 */
	void remove(T object);
	/**
	 * 根据id删除一个对象
	 * @param id
	 */
	void remove(Serializable id);
	
	/**
	 * 保存一个对象，能处理修改和新增操作
	 * @param object
	 * @return
	 */
	T save(T object);
	
	
	/**缓存方法*//*
	
	*//**
	 * {@inheritDoc}
	 *//*
	public T get(Serializable id, IMemCachedClient memClient, String keyPre,
			String module, Integer objectId);

	*//**
	 * {@inheritDoc}
	 *//*
	public T getUniqueResult(final DetachedCriteria query,
			IMemCachedClient memClient, String keyPre, String module,
			Integer objectId);


	*//**
	 * {@inheritDoc}
	 *//*
	public int getCount(final DetachedCriteria query,
			IMemCachedClient memClient, String keyPre, String module,
			Integer objectId);

	*//**
	 * {@inheritDoc}
	 *//*
	public List<T> getList(final DetachedCriteria query,
			IMemCachedClient memClient, String keyPre, String module,
			Integer objectId);


	*//**
	 * {@inheritDoc}
	 *//*
	public List<T> getList(final DetachedCriteria query, final int firstResult,
			final int maxResults, IMemCachedClient memClient, String keyPre,
			String module, Integer objectId);


	public List<T> getListBySQL(final String sql,
			final Map<String, Object> map, final Class c,
			IMemCachedClient memClient, String keyPre, String module,
			Integer objectId);

	public List getListBySQL2(final String sql, final Map<String, Object> map,
			final Class c, IMemCachedClient memClient, String keyPre,
			String module, Integer objectId);

	public List<Object[]> getListBySQL(final String sql,
			final Map<String, Object> map, IMemCachedClient memClient,
			String keyPre, String module, Integer objectId) ;


	public List<T> getList(final String hql, final Map<String, Object> map,
			IMemCachedClient memClient, String keyPre, String module,
			Integer objectId);

	public Integer getCountBySQL(final String sql,
			final Map<String, Object> map, IMemCachedClient memClient,
			String keyPre, String module, Integer objectId);

	public Integer getCount(final String hql, final Map<String, Object> map,
			IMemCachedClient memClient, String keyPre, String module,
			Integer objectId);*/

}
